<?php
require_once "Imified.php";
require_once "SecureStorage.php";

class ImifiedBot extends Imified {
    /**
     * 
     * @var SecureStorage
     */
    protected $storage = null;
    
    public function processRequest() {
        try {
            $this->storage = new SecureStorage($this->getUser(), dirname(__FILE__) . "/secure/");
            
            $methodName = "step" . $this->getStep();
            if (method_exists($this, $methodName)) {
                $this->log("Calling method $methodName()");
                $this->$methodName();
            }
            elseif (method_exists($this, "stepN")) {
                $this->log("Calling method stepN()");
                $this->{"stepN"}();
            }
            else {
                $this->answerReset("Method $methodName does not exist");
                $this->log("Method $methodName does not exist", 1);
            }
        }
        catch (Exception $e) {
            $this->log("Exception: " . $e->getMessage() . " @ " . $e->getFile() . ":" . $e->getLine() . "\nStack:\n" . $e->getTraceAsString(), 1);
            $this->answerReset("");
            throw $e;
        }
    }
}

